<template>
  <div>
    <div class="bg-white grid-content">
      <div style="overflow: hidden; ">
        <div class="mytitle"><svg-icon icon-class="csbb" class="myIcon" /> 测试报表</div>
        <div class="myButtons">
          <el-button @click="handleClick('', 'add')">新增</el-button>
          <a :href=token><el-button style="margin: 0 10px;">下载模板</el-button></a>
          <el-button
            class="import-button"
            @click="uploadFiles"
          >
            <i class="icon"></i>
            批量导入
          </el-button>
          <el-dialog title="批量导入" :visible.sync="importDialog" class="dialog-md" width="500px" :before-close="handleClose1">
            <el-form ref="fileForm" label-position="center" style="width: 100%" enctype="multipart/form-data">
              <el-form-item align="center" label="">
                <el-upload
                  ref="upload"
                  class="uploadDialog"
                  name="myfile"
                  action="string"
                  :http-request="httpRequest"
                  :on-change="handleChange"
                  :on-remove="handleRemove"
                  :limit="1"
                  :file-list="fileList"
                  accept=".xlsx,.xls"
                  :auto-upload="true"
                >
                  <el-button slot="trigger" size="small" type="primary">上传文件</el-button>
                  <div class="el-upload__tip" style="color: grey;">建议下载模板进行导入</div>
                  <div class="el-upload__tip">1.仅支持上传.xls、.xlsx文件</div>
                  <div class="el-upload__tip">2.文件数据不能超过1000条</div>

                </el-upload>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button size="small" @click="cancelUpload()">取消</el-button>
                <el-button type="primary" size="small" @click="upload()" :disabled="uploading">确定导入</el-button>
              </span>
          </el-dialog>
        </div>
      </div>
      <!-- 表格 -->
      <el-table
        :data="tableData"
        :header-cell-style="{ background: '#F5F7FA', color: '#909399' }"
        border
        stripe
      >
        <el-table-column
          align="center"
          type="index"
          label="序号"
          :index="indexMethod"
          width="60"
          fixed="left"
        >
        </el-table-column>
        <el-table-column align="center" prop="zyq" label="作业区"></el-table-column>
        <el-table-column align="center" prop="db" label="队别"></el-table-column>
        <el-table-column align="center" prop="jh" label="井号"></el-table-column>
        <el-table-column align="center" prop="cyfs" label="采油方式"></el-table-column>
        <el-table-column align="center" prop="qdfs" label="驱动方式"></el-table-column>
        <el-table-column align="center" prop="rq" label="日期"></el-table-column>
        <el-table-column align="center" prop="ty" label="套压(Mpa)"></el-table-column>
        <el-table-column align="center" prop="yy" label="油压(Mpa)"></el-table-column>
        <el-table-column align="center" prop="rcy1" label="日产液(t)"></el-table-column>
        <el-table-column align="center" prop="rcy2" label="日产油(t)"></el-table-column>
        <el-table-column align="center" prop="hs" label="含水(%)"></el-table-column>
        <el-table-column align="center" prop="cc1" label="冲程(m)"></el-table-column>
        <el-table-column align="center" prop="cc2" label="冲次(次/min)"></el-table-column>
        <el-table-column align="center" prop="bj" label="泵径(mm)"></el-table-column>
        <el-table-column align="center" prop="lp" label="理排(t/d)"></el-table-column>
        <el-table-column align="center" prop="bx" label="泵效(%)"></el-table-column>
        <el-table-column align="center" prop="yczs" label="油层中深(m)"></el-table-column>
        <el-table-column align="center" prop="bg" label="泵挂(m)"></el-table-column>
        <el-table-column align="center" prop="dym" label="动液面(m)"></el-table-column>
        <el-table-column align="center" prop="cmd" label="沉没度(m)"></el-table-column>
        <el-table-column align="center" prop="ly" label="流压(MPa)"></el-table-column>
        <el-table-column align="center" prop="sdl" label="上电流(A)"></el-table-column>
        <el-table-column align="center" prop="xdl" label="下电流(A)"></el-table-column>
        <el-table-column align="center" prop="phb" label="平衡比(%)"></el-table-column>
        <el-table-column align="center" prop="sjzdzh" label="实际最大载荷(KN)"></el-table-column>
        <el-table-column align="center" prop="sjzxzh" label="实际最小载荷(KN)"></el-table-column>
        <el-table-column align="center" prop="gtfx" label="功图分析"></el-table-column>
        <el-table-column align="center" prop="jcsb" label="降参设备"></el-table-column>
        <el-table-column align="center" prop="jnsb" label="节能设备"></el-table-column>
        <el-table-column align="center" prop="jksb" label="井口设备有井口防盗箱(可以打开)"></el-table-column>
        <el-table-column align="center" prop="jyqk" label="加药情况"></el-table-column>
        <el-table-column align="center" prop="jcyf" label="间抽与否"></el-table-column>
        <el-table-column align="center" prop="bz" label="备注"></el-table-column>
        <el-table-column align="center" prop="cgj" label="长关井"></el-table-column>
        <el-table-column align="center" prop="lgj" label="临关井"></el-table-column>
        <el-table-column align="center" prop="jhgj" label="计划关井"></el-table-column>


        <el-table-column align="center" prop="approveStatus" label="审核">
          <template slot-scope="scope">
            <el-button v-if="scope.row.approveStatus == 0" @click="handSubmit(scope.row)" type="text" style="color: orange">提交审核</el-button>
            <el-tooltip v-else :content="scope.row.approveBz" placement="right" effect="light" :disabled="!scope.row.approveBz">
              <el-badge :is-dot="scope.row.approveBz!=''&&scope.row.approveBz!=null" class="item">
                <el-tag :class="scope.row.approveBz?'tagstyle':''"
                        :type="
                      scope.row.approveStatus == '5'
                      ?'success'
                      :scope.row.approveStatus == '4'
                        ? 'danger'
                        : scope.row.approveStatus == '3'
                          ? ''
                          :scope.row.approveStatus == '2'
                            ? 'danger'
                            :scope.row.approveStatus == '1'
                              ? 'warning'
                              :'info'"
                        disable-transitions>{{
                    scope.row.approveStatus == '5'
                      ?'管理部通过'
                      :scope.row.approveStatus == '4'
                        ? '管理部未通过'
                        : scope.row.approveStatus == '3'
                          ? '作业区通过待管理部审核'
                          :scope.row.approveStatus == '2'
                            ? '作业区未通过'
                            :scope.row.approveStatus == '1'
                              ? '已上报待作业区审核'
                              :'待上报'
                  }}</el-tag>
              </el-badge>
            </el-tooltip>
          </template>
        </el-table-column>

        <el-table-column align="center" label="操作" width="140" fixed="right">
          <template slot-scope="scope">
            <el-button
              @click="handleClick(scope.row, 'check')"
              type="text"
              style="color: #2ec02e"
            >查看</el-button
            >
            <el-button @click="handleClick(scope.row, 'edit')" type="text"
            >编辑</el-button
            >
            <el-button
              @click="handleDelete(scope.row)"
              type="text"
              style="color: red"
            >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页器 -->
      <el-pagination align='right'
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNo"
          :page-sizes="[5,10, 20, 30, 40, 50]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
    </div>

    <!-- 弹出框 -->
    <el-dialog
      :title="myDialogTitle"
      :visible.sync="dialogFormVisible"
      :before-close="handleClose"
      custom-class="saveAsDialog"
    >

      <el-form
        :inline="true"
        :model="csbbForm"
        class="demo-form-inline"
        :rules="rules"
        ref="csbbForm"
        :disabled="isInput"
        label-position="left"
        label-width="130px"
      >
        <!-- <el-divider content-position="left">基础信息</el-divider> -->

        <el-divider content-position="left">基础信息</el-divider>

        <el-row>
          <el-col :span="12">
            <el-form-item label="作业区:">
              <el-input
                v-model="csbbForm.zyq"
                placeholder="请输入作业区"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="队别:">
              <el-input
                v-model="csbbForm.db"
                placeholder="请输入队别"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="12">
            <el-form-item label="井号:">
              <el-input
                v-model="csbbForm.jh"
                placeholder="请输入井号"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日期:">
              <el-date-picker
                v-model="csbbForm.rq"
                type="date"
                placeholder="选择日期时间"
                align="right"
                :picker-options="pickerOptions"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>

        <el-divider content-position="left">数据信息</el-divider>
        <el-row>
          <el-col :span="12">
            <el-form-item label="采油方式:">
              <el-input
                v-model="csbbForm.cyfs"
                placeholder="请输入采油方式"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="驱动方式:">
              <el-input
                v-model="csbbForm.qdfs"
                placeholder="请输入支部"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="套压(MPa):">
              <el-input
                v-model="csbbForm.ty"
                placeholder="请输入套压"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="油压(MPa):">
              <el-input
                v-model="csbbForm.yy"
                placeholder="请输入油压"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="日产液(t):">
              <el-input
                v-model="csbbForm.rcy1"
                placeholder="请输入日产液"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="日产油(t):">
              <el-input
                v-model="csbbForm.rcy2"
                placeholder="请输入日产油"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="含水(%):">
              <el-input
                v-model="csbbForm.hs"
                placeholder="请输入含水"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="冲程(m):">
              <el-input
                v-model="csbbForm.cc1"
                placeholder="请输入冲程"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="冲次(次/min):">
              <el-input
                v-model="csbbForm.cc2"
                placeholder="请输入冲次"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="泵径(mm):">
              <el-input
                v-model="csbbForm.bj"
                placeholder="请输入泵径"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="理排(t/d):">
              <el-input
                v-model="csbbForm.lp"
                placeholder="请输入理排"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="泵效(%):">
              <el-input
                v-model="csbbForm.bx"
                placeholder="请输入泵效"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="油层中深(m):">
              <el-input
                v-model="csbbForm.yczs"
                placeholder="请输入油层中深"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="泵挂(m):">
              <el-input
                v-model="csbbForm.bg"
                placeholder="请输入泵挂"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="动液面(m):">
              <el-input
                v-model="csbbForm.dym"
                placeholder="请输入动液面"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="沉没度(m):">
              <el-input
                v-model="csbbForm.cmd"
                placeholder="请输入沉没度"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="流压(MPa):">
              <el-input
                v-model="csbbForm.ly"
                placeholder="请输入流压"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="平衡比(%):">
              <el-input
                v-model="csbbForm.phb"
                placeholder="请输入平衡比"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="上电流(A):">
              <el-input
                v-model="csbbForm.sdl"
                placeholder="请输入上电流"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下电流(A):">
              <el-input
                v-model="csbbForm.xdl"
                placeholder="请输入下电流"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="实际最大载荷(KN):">
              <el-input
                v-model="csbbForm.sjzdzh"
                placeholder="请输入实际最大载荷"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实际最小载荷:">
              <el-input
                v-model="csbbForm.sjzxzh"
                placeholder="请输入实际最小载荷"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="功图分析:">
              <el-input
                v-model="csbbForm.gtfx"
                placeholder="请输入功图分析"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="降参设备:">
              <el-input
                v-model="csbbForm.jcsb"
                placeholder="请输入降参设备"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="节能设备:">
              <el-input
                v-model="csbbForm.jnsb"
                placeholder="请输入节能设备"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="井口设备:">
              <el-input
                v-model="csbbForm.jksb"
                placeholder="请输入井口设备"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="加药情况:">
              <el-input
                v-model="csbbForm.jyqk"
                placeholder="请输入加药情况"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="间抽与否:">
              <el-input
                v-model="csbbForm.jcyf"
                placeholder="请输入间抽与否"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="备注:">
              <el-input type="textarea" v-model="csbbForm.bz"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="长关井:">
              <el-input
                v-model="csbbForm.cgj"
                placeholder="请输入长关井数"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="临关井:">
              <el-input
                v-model="csbbForm.lgj"
                placeholder="请输入临关井数"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="计划关井:">
              <el-input
                v-model="csbbForm.jhgj"
                placeholder="请输入计划关井数"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>

      <div slot="footer" class="dialog-footer" v-show="!ischeck">
        <el-button @click="close('csbbForm')">取 消</el-button>
        <el-button type="primary" @click="submitForm('csbbForm')">确 定</el-button>
      </div>
      <div slot="footer" class="dialog-footer" v-show="ischeckSh">
        <el-button type="primary" @click="submitSh('csbbForm')">提交审核</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import axios from "axios";
import csbbApi from '@/api/csbb';
import { getToken } from "@/utils/auth";
import xfsbjcsjApi from "@/api/jcsj/aqyx/xf/xfsbjcsj";

export default {
  data() {
    return {
      leve:'',
      pageNo: 1, //当前页码
      pageSize: 10, //每页显示数量
      total: 0, //总数量
      // table数据
      tableData: [],
      //当前页码
      currentPage: 1,
      //表单填报的数据
      csbbForm: {
        id:'',
        zyq: "", //作业区
        db: "", //队别
        jh: "", //井号
        cyfs: "", //采油方式
        qdfs: "", //驱动方式
        rq: "", //日期
        ty: "", //套压
        yy: "", //油压
        rcy1: "", //日产液
        rcy2: "", //日产油
        hs: "", //含水
        cc1: "", //冲程
        cc2: "", //冲次
        bj: "", //泵径
        lp: "", //理排
        bx: "", //泵效
        yczs: "", //油层中深
        bg: "", //泵挂
        dym: "", //动液面
        cmd: "", //沉没度
        ly: "", //流压
        sdl: "", //上电流
        xdl: "", //下电流
        phb: "", //平衡比
        sjzdzh: "", //实际最大载荷
        sjzxzh: "", //实际最小载荷
        gtfx: "", //功图分析
        jcsb: "", //降参设备
        jnsb: "", //节能设备
        jksb: "", //井口设备
        jyqk: "", //加药情况
        jcyf: "", //间抽与否
        bz: "", //备注
        cgj: "", //长关井
        lgj: "", //临关井
        jhgj: "", //计划关井
        approveStatus:'',
        approveBz:'',
        fileList:[]
      },
      //验证规则
      rules: {
        zyq: [{ required: true, message: "请输入作业区", trigger: "blur" }],
        db: [{ required: true, message: "请输入队别", trigger: "blur" }],
        rq: [{ required: true, message: "选择日期时间", trigger: "change" }],
      },
      //时间快捷选择
      pickerOptions: {
        // disabledDate(time) {
        //   return time.getTime() > Date.now();
        // },
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date());
          }
        }, {
          text: '昨天',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24);
            picker.$emit('pick', date);
          }
        }, {
          text: '一周前',
          onClick(picker) {
            const date = new Date();
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', date);
          }
        }]
      },
      //获取当前日期
      currentTime:'',
      //编辑框是否显示
      dialogFormVisible: false,
      //弹出框是否是查看
      ischeck: false,
      //弹出框是否有提交审核按钮
      ischeckSh: false,
      //控制查看时不可更改数据
      isInput:false,
      //弹出框标题
      myDialogTitle: '',

      file: null,
      //加载动画
      uploadLoading: false,
      //控制弹出框显示与否
      uploadShowDialog: false,
      //上传地址
      uploadURL: '',
      //loading加载中
      downloadLoading: '',
      importDialog:false,
      urlFile:'',
      uploading:true,
    }
  },
  created(){
    this.search();
    this.data.leve = sessionStorage.getItem("userLeve");

  },
  mounted(){
    this.filterTime();
    // this.initDate();
    this.token = "http://47.108.251.250:3296/api/csbb/downLoadExcel?token=" + getToken();
  },
  methods: {
    /**
    * 查询列表
    */
    async search() {
      // this.pageNo = pageNo; //当前页码
      // this.pageSize = pageSize; //每页显示数量
      //发送查询请求
      let res = await csbbApi.getCsbbList(this.pageNo,this.pageSize);
      //判断是否成功
      if(res.success){
        console.log(res.data);
        //赋值
        this.tableData = res.data.records;
        //总数量
        this.total = res.data.total;
      }
    },
    onSubmit() {
      console.log('submit!');
    },
    //关闭对话框
    handleClose(done) {
      // 清空表单
      // this.$refs['csbbForm'].resetFields();
      // 清空表单校验，避免再次进来会出现上次校验的记录
      this.$refs['csbbForm'].clearValidate()
      done()

    },
    handleClose1(done) {
      this.urlFile = ''
      this.fileList =[];
      done()
    },
      // 弹框关闭触发
    close(formName) {
      this.dialogFormVisible = false;
      // 清空表单
      // this.$refs[formName].resetFields();
      // 清空表单校验，避免再次进来会出现上次校验的记录
      this.$refs[formName].clearValidate()
    },

    submitForm(formName) {
      //表单验证
      this.$refs[formName].validate(async (valid) => {
        if (valid) {
          let res = null;
          console.log("111" + this.csbbForm.sbid);
          //判断ID是否为空
          if (this.isadd) {
            console.log(this.csbbForm);
            //发送添加请求
            res = await csbbApi.addCsbb(this.csbbForm);
          } else {
            this.csbbForm.approveStatus = 0
            this.csbbForm.approveBz = ''
            //发送修改请求
            res = await csbbApi.updateCsbb(this.csbbForm);
          }
          console.log(res);
          //判断是否成功
          if (res.success) {
            this.$message.success(res.message);
            //刷新
            this.search();
            //关闭窗口
            this.dialogFormVisible = false;
          } else {
            console.log(res);
            this.$message.error(res.message);
          }
        }
      });
    },
    handleClick(row, handle) {
      // console.log(row.approveStatus);
      this.dialogFormVisible = true;
      if (handle == "check") {
        this.myDialogTitle = "测试报表数据";
        this.ischeck = true;
        this.isInput = true; // 1.表单禁用
        // this.cybzjcsjForm = row
        this.$objCopy(row, this.csbbForm); //把当前要编辑的数据复制到数据域，给表单回显
        this.$message({ message: "成功打开", type: "success" });
      } else if (handle == "edit") {
        if(row.approveStatus == 0 || row.approveStatus == 2 || row.approveStatus == 4){
          this.myDialogTitle = '测试报表编辑'
          this.ischeck = false
          this.isadd = false
          this.isInput = false
          this.$objCopy(row, this.csbbForm);//把当前要编辑的数据复制到数据域，给表单回显
        }else{
          this.dialogFormVisible = false;
          this.$message.error('此状态不可编辑！');
        }
      } else if (handle == "add") {
        // this.jianjcsjForm ={}
        this.$resetForm("bjcsjForm", this.csbbForm); //清空表单数据
        this.myDialogTitle = "测试报表填报";
        this.ischeck = false;
        this.isInput = false;
        this.isadd = true;
      }
    },
    //删除行数据
    async handleDelete(row) {
      console.log(row)
      if(row.approveStatus == 0 || row.approveStatus == 2 || row.approveStatus == 4 || this.leve == 999 || this.leve == 1000){
        let confirm = await this.$myconfirm("确定要删除该数据吗?");
        console.log(confirm)
        if (confirm) {
          //发送删除请求
          let res = await csbbApi.delete({ id:row.id});
          console.log(res)
          debugger
          //判断是否成功
          if (res.success) {
            //成功提示
            this.$message.success(res.message);
            //刷新
            this.search();
          } else {
            //失败提示
            this.$message.error(res.message);
          }
        }
      }else{
        this.$message.error('此状态不可删除！');
      }

    },
    uploadFiles() {
      this.importDialog = true
      this.urlFile = ''
    },
    cancelUpload(){
      this.urlFile = ''
      this.fileList = [];
      this.importDialog = false
    },
    //  监听改变
    handleChange(file, fileList) {
      this.fileList = fileList
    },
    // 移除
    handleRemove(file, fileList) {
      this.fileList = fileList
    },
    beforeAvatarUpload(file) {
      //1MB=1024*1024(1MB=1024KB 1KB=1024MB)
      const is10M = file.size / 1024 / 1024 < 10;
       //限制文件上传大小
      if (!is10M) {
        this.$message.error("上传图片大小不能超过 10MB!");
        return false
      }
      return true
    },
    //上传成功之后清除历史记录
    // handleSuccess(fileList) {
    //   this.fileList = [];
    //   this.$refs['fileForm'].upload.clearFiles()
    // },
    // 自定义上传Excel方法
    httpRequest(param) {
      // console.log(param.file);
      this.uploading = true;
      const File = this.fileList[0].raw;
      // const File = param.file
      console.log(File);
      // console.log(this.fileList);
      let formData = new FormData();
      formData.append("myfile", File);
      console.log(formData.get("myfile"));

      axios({
      url: "http://47.108.251.250:3296/api/fileAbout/fileUpload",
      method: "post",
      headers: {
        "token": getToken(),
        "Content-Type": "multipart/form-data",
      },
      data: formData,
        }).then(
          (response) => {
            if (response.data.success === true && response.data.data!=="") {
              console.log(response.data);
              this.urlFile = response.data.data;
              console.log(this.urlFile);
              this.$message.success(response.data.message);
              param.onSuccess();
              this.uploading = false;
            }else{
              this.$message.error('上传失败');
            }
          },
          (error) => {
            console.log(error);
            this.$message.error(response.data.message);
          }
        );
    },
    //文件导入
    upload(){
      let formData = new FormData();
      formData.append("filePath",this.urlFile);
      console.log(formData.get("filePath"));
      axios({
      url: "http://47.108.251.250:3296/api/csbb/batchInput",
      method: "post",
      headers: {
        "token": getToken(),
        "Content-Type": "multipart/form-data",
      },
      data: formData,
        }).then(
          (response) => {
            if (response.data.success === true) {
              console.log(response.data);
              this.$message.success(response.data.message);
              //刷新
              this.search();
              //关闭窗口
              this.importDialog = false;
              this.fileList = [];
            }else{
              this.$message.error('导入失败');
            }
          },
          (error) => {
            console.log(error);
            this.$message.error(response.data.message);
          }
        );
    },
    /*** 当每页数量发生变化时触发该事件 */
    handleSizeChange(size) {
      console.log(size);
      this.pageSize = size;
      //将每页显示的数量交给成员变量
      this.search(this.pageNo, size);
    },
    /*** 当页码发生变化时触发该事件 */
    handleCurrentChange(page) {
      console.log(page);
      this.pageNo = page;
      //调用查询方法
      this.search(page, this.pageSize);
    },
    // 序号计算
    indexMethod (index) {
    // index默认在0开始，这里+1
      return index + 1 + (this.pageNo - 1) * this.pageSize
    },
    // 获取当前日期
    filterTime() {
      var date = new Date();
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? '0' + m : m;
      var d = date.getDate();
      d = d < 10 ? '0' + d : d;
      this.currentTime = y + '-' + m + '-' + d;
    },
    //上报
    handSubmit(row){
      this.$confirm('确定提交审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        let res = null;
        this.$objCopy(row, this.csbbForm);
        //审核
        this.csbbForm.approveStatus = 1
        console.log(this.csbbForm);
        res = await csbbApi.updateCsbb(this.csbbForm);

        console.log(res)
        //判断是否成功
        if (res.success) {
          // this.$message.success(res.message);
          this.$message({ message: '提交审核成功！', type: 'success' });
          //刷新
          this.search();

        } else {
          console.log(res)
          this.$message.error(res.message);
        }
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消'
        });
      });

    },
  }
}
</script>

<style lang="scss" scoped>
// 标题
.mytitle {
  font-size: large;
  padding-left: 10px;
  margin-bottom: 16px;
  float: left;
}

//按钮组
.myButtons {
  float: right
}

//格子的样式
.bg-white {
  background: #ffffff;
}

.grid-content {
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.calendar ::v-deep .el-button-group::before {
  display: none;
}

.calendar ::v-deep .el-button-group::after {
  display: none;
}

// 分割线样式
.el-divider--horizontal {
  display: block;
  height: 2px;
  width: 100%;
  margin: 24px 0;
}

// 表单各项的样式
.el-form-item {
  margin: 15px 10px 15px 10px;
}

//表单禁用字体样式
.el-input.is-disabled ::v-deep .el-input__inner {
    color: #606266;
  }
//对话框宽度
// .customWidth{
//         width:80%;
//     }
::v-deep .saveAsDialog {
  width: 60% !important;
}

::v-deep .el-table .cell{overflow: unset}

.el-date-editor.el-input, .el-date-editor.el-input__inner { width: 180px; }

.el-input {
  width: 180px;
}
.tagstyle{
  cursor: pointer;
}
</style>
